# Contributor: techknowlogick <techknowlogick@gitea.io>
# Maintainer: techknowlogick <techknowlogick@gitea.io>
pkgname=helm
pkgver=3.9.0
pkgrel=1
pkgdesc="The Kubernetes Package Manager"
url="https://helm.sh/"
arch="all !armhf" # unit tests fails with armhf
license="Apache-2.0"
makedepends="bash go"
options="net"
subpackages="$pkgname-bash-completion $pkgname-fish-completion $pkgname-zsh-completion"
source="$pkgname-$pkgver.tar.gz::https://github.com/helm/helm/archive/v$pkgver.tar.gz"

# secfixes:
#   3.6.0-r0:
#     - CVE-2021-21303
#   3.6.1-r0:
#     - CVE-2021-32690

case "$CARCH" in
	# Disable check on 32bit systems due to upstream test "TestPlatformPrepareCommand" that does not account for these platforms
	x86|armv7) options="$options !check" ;;
esac

export GOPATH="$srcdir/go"
export GOCACHE="$srcdir/go-build"
export GOTEMPDIR="$srcdir/go"

export GOFLAGS="$GOFLAGS -modcacherw"
export CGO_ENABLED=0

build() {
	export CGO_ENABLED=0 # breaks on aarch64
	make GOFLAGS="$GOFLAGS" GIT_TAG="v$pkgver" GIT_COMMIT="" GIT_DIRTY=""

	./bin/helm completion bash > $pkgname.bash
	./bin/helm completion fish > $pkgname.fish
	./bin/helm completion zsh > $pkgname.zsh
}

check() {
	make test-unit GOFLAGS="$GOFLAGS"
}

package() {
	install -Dm755 bin/helm -t "$pkgdir/usr/bin"

	install -Dm644 $pkgname.bash "$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 $pkgname.fish "$pkgdir"/usr/share/fish/completions/$pkgname.fish
	install -Dm644 $pkgname.zsh "$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
8d5dc0627b1e7c7dba6774b8824002036d84f06999d7d73234f3ed5f1eb4053f92c3a42d8a37e2f4e9b3e04de821b7e528be2edfc665647c76bc79ef6c42ec1c  helm-3.9.0.tar.gz
"
